package com.lei.Proxy.statics;

/**
 * @author: leiGer
 * @Date: 2021/01/14
 * @Time: 22:43
 */
//真实手机
public class MobilePhone implements Phone {
    //品牌
    private String brand;
    //型号
    private String series;
    //颜色
    private String color;


    public MobilePhone(String brand, String series, String color) {
        this.brand = brand;
        this.series = series;
        this.color = color;
    }

    public MobilePhone() {
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public void setSeries(String series) {
        this.series = series;
    }

    public void setColor(String color) {
        this.color = color;
    }
    @Override
    public String getBrand() {
        return brand;
    }

    @Override
    public String getSeries() {
        return series;
    }

    @Override
    public String getColor() {
        return color;
    }

    //重写call方法
    @Override
    public void call() {
        System.out.println(getColor() + "颜色的"+getBrand()+getSeries()+"手机开始拨打电话");
    }

    //下面两段代码是用于Map中比较是否一致，需重写equals和hashmap方法
    @Override
    public boolean equals(Object o) {
        MobilePhone mp = null;
        try {
            mp = (MobilePhone)o;
        } catch (Exception e) {
             return false;
        }
        if(getBrand().equals(mp.getBrand())
        &&getSeries().equals(mp.getSeries())
        &&getColor().equals(mp.getColor())){
            return true;
        }else{
            return false;
        }

    }

    @Override
    public int hashCode() {
        return getColor().hashCode()&getSeries().hashCode()&getBrand().hashCode();
    }
}
